import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.dis.ibs.fileuploader.*;
import java.util.*;

public class StartaApplet extends HttpServlet{
    
    PrintWriter out;
    
    
    public void doPost(HttpServletRequest req, HttpServletResponse res){
        doView(req,res);
    }
    
    public void doGet(HttpServletRequest req, HttpServletResponse res){
        doView(req,res);
    }
    
/*
  public String getServletInfo(){
    return "This servlet can view tables in a MySQL data base";
  }
 */
    
//----------------------doView---------------------------------**
    
    public void doView(HttpServletRequest req, HttpServletResponse res){
        
        String titel = "";
        String saljare = "";
        String budgivare = "";
        String bud = "";
        
        try{
            try{
                out = res.getWriter();
            }catch(IOException e){}//try-catch
            
            HttpSession ses = req.getSession(true);
            
            DBkoppling.setKoppling();
            ResultSet rs = null;
            
            titel = (String)ses.getAttribute("titel");
            
            try{
                rs = DBkoppling.getInfo(titel,"Vara","titel");
            }catch(Exception e){}//try-catch
            
            if(rs.first()){
                saljare = rs.getString(6);
                rs=null;
            }//if
            
            try{
                rs = DBkoppling.getBud(titel);
            }catch(SQLException se){}//try-catch
            
            if(rs.first()){
                budgivare =	rs.getString(2);
                bud = rs.getString(3);
            }//if
            
            out.println("<html>");
            out.println("<head>");
            out.println("</head>");
            out.println("<body>");
            out.println("<center>");
            out.println("<applet code=Klient.class height=200 width=360>");
            out.println("<param name=vara value="+titel+">");
            out.println("<param name=saljare value="+saljare+">");
            out.println("<param name=budgivare value="+budgivare+">");
            out.println("<param name=bud value="+bud+">");
            out.println("</applet>");
            out.println("</center>");
            out.println("</body>");
            out.println("</html>");
            
        }catch(Exception e){
            e.printStackTrace(System.out);            
        }//try-catch
        finally{
            DBkoppling.kopplaNer();
        }
    }//end doView
}//end class




